/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tletlis.model;

import java.util.ArrayList;
import java.util.NoSuchElementException;

/**
 *
 * @author Gustav
 */
public class Row {

    private ArrayList<GamePosition> GamePosList;

    private int rowNr;

    private int yCord;

    public Row(int rowNr, int nrOfElements) {

        this.rowNr = rowNr;

        yCord = rowNr*Position.getLength();
        GamePosList = new ArrayList<GamePosition>();
        for(int i = 0; i < nrOfElements; i++) {
            GamePosList.add(new GamePosition(yCord,i*Position.getLength()));
        }
        
    }

    /*public boolean isRightRow(int y) {
        if(y == yCord)
            return true;
        return false;
    }*/

    public GamePosition getPosition(Position p) {

        for(GamePosition pos: getGamePosList()) {
            if(pos.equals(p))
                return pos;
        }
        throw new NoSuchElementException("The Position does not exist");
    }

    public int getRowNr() {
        return rowNr;
    }

    /**
     * @return the yCord
     */
    public int getYCord() {
        return yCord;
    }

    /**
     * @return the GamePosList
     */
    public ArrayList<GamePosition> getGamePosList() {
        return GamePosList;
    }


}
